import ElementPlus from 'element-plus'
import '../element-variables.scss'
import locale from 'element-plus/lib/locale/lang/zh-cn'
import { createApp } from "vue";
import { FieldErrorList, RuleItem } from 'async-validator';
// import { ValidateFieldCallback } from 'element-plus/lib/el-form/src/token';
import { defineComponent } from 'vue';


export interface ElOtherRuleItem {
  trigger?: string | string[];
}

export declare type ElRuleItem = RuleItem | ElOtherRuleItem;
type Callback = (isValid?: boolean, invalidFields?: FieldErrorList) => void;
interface ElFormType {
  validate: (callback?: Callback) => Promise<boolean>;
  resetFields: () => void;
  clearValidate: (props?: string | string[]) => void;
  validateField: (props: string | string[]) => void;
}

export declare type ElFormComponent = ElFormType | ReturnType<typeof defineComponent>;

export default (app: ReturnType<typeof createApp>) : void => {
  app.use(ElementPlus, { locale })
}
